<?php
require_once "http-request.php";

abstract class RequestPrototype {
	protected $httpRequest;
	protected $requestUrl;
	
	abstract function __clone();
	
	function makeRequest($url, $username = "", $password = "", $args = null) {
		$this->httpRequest->setRequestUrl($url);
		
		if ($this->user_name != "" && $this->password != "") {
           $this->httpRequest->setAuthentication($username, $password);
        }
        if ($args != null) {
        	$this->httpRequest->setRequestData($args);
        }
        $this->httpRequest->sendRequest();
        return $this->httpRequest->getResponse();
	}
}

/** -------------------------------------------
 ******* Request Prototype implementors ******* 
 */
class RestGetRequest extends RequestPrototype {
	function __construct() {
	  $this->httpRequest =& new HttpRequest();
      $this->httpRequest->setRequestMethod(HTTP_REQUEST_METHOD_GET);
    }

    function __clone() 
    { 
    	$this->httpRequest = clone $this->httpRequest;
    }
}

class RestPostRequest extends RequestPrototype {
	function __construct() {
	  $this->httpRequest =& new HttpRequest();
      $this->httpRequest->setRequestMethod(HTTP_REQUEST_METHOD_POST);
    }

    function __clone() {
    	$this->httpRequest = clone $this->httpRequest;
    }
}

class RestPutRequest extends RequestPrototype {
	function __construct() {
	  $this->httpRequest =& new HttpRequest();
      $this->httpRequest->setRequestMethod(HTTP_REQUEST_METHOD_PUT);
    }

    function __clone() { 
    	$this->httpRequest = clone $this->httpRequest;
    }
}

class RestDeleteRequest extends RequestPrototype {
	function __construct() {
	  $this->httpRequest =& new HttpRequest();
      $this->httpRequest->setRequestMethod(HTTP_REQUEST_METHOD_DELETE);
    }

    function __clone() {
    	$this->httpRequest = clone $this->httpRequest;
    }
}

?>